import torch
from torch import nn


class SimpleNet(nn.Module):
    def __init__(self, num_classes, in_channels):
        super(SimpleNet, self).__init__()
        self.net = nn.Sequential(

        )
        self.conv1 = nn.Conv2d(in_channels, 32, kernel_size=3, padding=1)  # 输入层 (3是因为CIFAR-10的图片是3通道的)
        self.conv2 = nn.Conv2d(32, 64, kernel_size=3, padding=1)
        self.pool = nn.MaxPool2d(kernel_size=2, stride=2)
        self.fc1 = nn.Linear(200704, 512)  # 通过计算得出的全连接层的输入维度
        self.fc2 = nn.Linear(512, num_classes)  # 输出层 (10是因为CIFAR-10有10个类别)

    def forward(self, x):
        x = self.pool(torch.relu(self.conv1(x)))
        x = self.pool(torch.relu(self.conv2(x)))
        # x = x.view(-1, 64 * 8 * 8)  # 将卷积层的输出展平
        x = torch.flatten(x, start_dim=1)
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x